package officeserver.report;

import java.io.Serializable;

public class Invoice implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private String patient;

    private String doctor;

    private int day;

    private String[][] costs;

    /**
     * Creates a new invoice
     * 
     * @param patient
     *            creates a new patient for invoice
     * @param doctor
     *            creates a new doctor for invoice
     * @param day
     *            creates a new day for invoice
     * @param costs
     *            creates a new costs (which consists of type of work and
     *            amount) for invoice
     */
    public Invoice(String patient, String doctor, int day, String[][] costs) {
	this.patient = patient;
	this.doctor = doctor;
	this.day = day;
	this.costs = (costs != null) ? costs.clone() : null;
    }

    /**
     * gets the costs
     * 
     * @return costs
     */
    public String[][] getCosts() {
	return costs;
    }

    /**
     * sets costs
     * 
     * @param costs
     */
    public void setCosts(String[][] costs) {
	this.costs = costs.clone();
    }

    /**
     * Gets the patient who is receiving the invoice
     * 
     * @return patient
     */
    public String getPatient() {
	return patient;
    }

    /**
     * Sets the patient
     * 
     * @param patient
     */
    public void setPatient(String patient) {
	this.patient = patient;
    }

    /**
     * Gets the doctor who is involved with the invoice
     * 
     * @return doctor
     */
    public String getDoctor() {
	return doctor;
    }

    /**
     * sets the doctor
     * 
     * @param doctor
     */
    public void setDoctor(String doctor) {
	this.doctor = doctor;
    }

    /**
     * Gets the day when the invoice was issued
     * 
     * @return day
     */
    public int getDay() {
	return day;
    }

    /**
     * sets the day
     * 
     * @param day
     */
    public void setDay(int day) {
	this.day = day;
    }

    /**
     * Updates the Invoice. It will check (for Strings) if there is a field in
     * Invoice update that is filled out. If not, it'll use the current
     * invoice's information. If it is, it will set the current invoice's
     * information to update's information.
     * 
     * @param update
     *            Invoice object with the newest information
     */
    public void updateInvoice(Invoice update) {
	if (update != null) {
	    this.doctor = (update.getDoctor() == null) ? this.doctor
		    : new String(update.getDoctor());
	    this.patient = (update.getPatient() == null) ? this.patient
		    : new String(update.getPatient());
	    this.day = update.getDay();
	    // this.costs = (update.getCosts() == null) ? this.costs
	    // : new String[][] update.getCosts();
	}
    }
}
